package com.xzwk.yn.serveradmin.controller;

import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;

public class IndexController {

    @FXML
    private Button dashboardBtn;

    @FXML
    private Button userManagementBtn;

    @FXML
    private Button settingsBtn;

    @FXML
    private AnchorPane centerRight;

    @FXML
    private Label contentTitle;

    @FXML
    private void handleMenuClick(javafx.event.ActionEvent event) {
        Button clickedButton = (Button) event.getSource();

        // 清除所有按钮的选中状态
        clearButtonSelection();

        // 设置当前按钮为选中状态
        clickedButton.setStyle("-fx-background-color: rgba(0, 144, 153, 0.5); -fx-text-fill: white; -fx-font-size: 14px; -fx-alignment: center-left; -fx-padding: 0 0 0 20;");

        // 根据点击的按钮加载不同的内容
        if (clickedButton == dashboardBtn) {
            contentTitle.setText("控制面板");
            // 加载控制面板内容
        } else if (clickedButton == userManagementBtn) {
            contentTitle.setText("用户管理");
            // 加载用户管理内容
        } else if (clickedButton == settingsBtn) {
            contentTitle.setText("系统设置");
            // 加载系统设置内容
        }
    }

    private void clearButtonSelection() {
        String defaultStyle = "-fx-background-color: transparent; -fx-text-fill: white; -fx-font-size: 14px; -fx-alignment: center-left; -fx-padding: 0 0 0 20;";
        dashboardBtn.setStyle(defaultStyle);
        userManagementBtn.setStyle(defaultStyle);
        settingsBtn.setStyle(defaultStyle);
    }

}
